package com.chefu.common.exception.controller;


import com.chefu.common.exception.pojo.ExceptionResult;
import com.chefu.common.exception.pojo.LyException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 自定义异常处理类
 */
@ControllerAdvice
public class LyExceptionController {

    /**
     * 异常处理方法
     */
    @ExceptionHandler(value = LyException.class)
    public ResponseEntity<ExceptionResult> handlerException(LyException e){
        return ResponseEntity.status(e.getStatus()).body(new ExceptionResult(e));
    }

}
